<template>
<div class="regbkimg">
  <div id="app">
    <vue-particles
        color="#dedede"
        :particleOpacity="0.7"
        :particlesNumber="100"
        shapeType="circle"
        :particleSize="4"
        linesColor="#dedede"
        :linesWidth="1"
        :lineLinked="true"
        :lineOpacity="0.4"
        :linesDistance="150"
        :moveSpeed="3"
        :hoverEffect="true"
        hoverMode="grab"
        :clickEffect="true"
        clickMode="push"
    >
    </vue-particles>
  </div>
  <el-card class="box-card" style="width: 600px;height:400px;margin: 0 auto;text-align: center;">
    <div><h1>注册密码</h1></div>

    <el-form :model="user" status-icon ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="账号" prop="acct">
        <el-input type="text" v-model="user.acct" ></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="paw">
        <el-input type="password" v-model="user.paw" ></el-input>
      </el-form-item>

    </el-form>
    <el-button @click="submitForm('ruleForm')" type="primary" round style="width: 200px;height: 60px;">立 即 注 册</el-button>

    </el-card>
</div>
</template>

<script>
export default {
  name: "register",
  data(){
    return{
      pwd:'',
      user:{}
    }
  },
  methods:{
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.rigte();
        } else {
          return false;
        }
      });
    },
    rigte() {
      // console.log(this.user)
      this.$axios.post('/api/user/register', this.user).then(res => {
        console.log(res)
        if (res.data.status === 1) {
          // console.log(res.data)
          // this.user=res.data.data
          // this.$message.success(res.data.msg);
          this.$router.push('/login');
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
  }
}
</script>

<style scoped>
.regbkimg{
  background-image: url("../img/bak2.jpg");
  position: relative;
}
.box-card{
  background-color:rgba(255, 255, 255, 0.3);
  border-radius:30px;
  position: absolute;
  top: 20%;
  left: 30%;
}
</style>